/*
angular.module('moti.controllers.regionscreat', ['moti.services.regionsService', 'directiveModule', 'moti.directive.modal', 'moti.directive.uploaderImg'])
    .controller('regionsCreatCtrl', ['$scope', '$location', '$routeParams', 'RegionsInterface', '$modal', function($scope, $location, $routeParams, RegionsInterface, $modal){

        //判断创建or修改
        $scope.edit = !!$routeParams.regionId;

        var editor = null;
        //修改页面情况获取当前景区接口
        if($scope.edit){
            RegionsInterface.getRegion($routeParams.regionId).then(function(data){
                $scope.region = data;
                //创建ckeditor，配置word粘贴时去除格式
                editor = CKEDITOR.replace("editor");
                editor.editorConfig = function(config){
                    config.pasteFromWordRemoveFontStyles = false;
                    config.pasteFromWordRemoveStyles = false;
                };
                setTimeout(function(){
                    editor.setData(data.content);
                }, 500);
            });
        }else{
            editor = CKEDITOR.replace("editor");
            editor.editorConfig = function(config){
                config.pasteFromWordRemoveFontStyles = false;
                config.pasteFromWordRemoveStyles = false;
            };
        }

        //景区价格保留2位小数
        $scope.fixAmount = function(amount){
            $scope.region.amount = parseFloat(amount).toFixed(2);
        };

        //提交
        $scope.regionsCreatForm = function(){
            if($scope.regions_creat_form.$valid){
                $scope.region.content = editor.getData();
                //tags可能是null或undefined
                if($scope.region.tags != undefined){
                    $scope.region.tags = $scope.region.tags.replace(/，/g, ",");
                }
                if($scope.edit){
                    RegionsInterface.putRegion($routeParams.regionId, $scope.region).then(function(data){
                        $modal({id : 'tip-modal', text : "修改景区成功"}).show().autoHide();
                        $location.path('/regionsList');
                    });
                }else{
                    RegionsInterface.postRegion($routeParams.regionId, $scope.region).then(function(data){
                        $modal({id : 'tip-modal', text : "创建景区成功"}).show().autoHide();
                        $location.path('/regionsList');
                    });
                }
            }
        }
    }]);*/

var regionsCreat = Vue.component('regionsCreat', { template: '#regionsCreat'});